package com.controller.backend;


import com.core.Result;
import com.core.ResultGenerator;
import com.qiniu.common.Config;
import com.qiniu.util.Auth;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by jc on 2017/10/09
 */
@Controller
@RequestMapping("/backend/security/qiniu")
public class QiniuController {

    @RequestMapping(value = "getUptoken")
    @ResponseBody
    public Result getUptoken() {
        Auth auth = Auth.create(Config.ACCESS_KEY, Config.SECRET_KEY);
        String bucketName = "image";
        return ResultGenerator.genSuccessResult(auth.uploadToken(bucketName));
    }

    @RequestMapping(value = "getVideoUptoken")
    @ResponseBody
    public Result getVideoUptoken() {
        Auth auth = Auth.create(Config.ACCESS_KEY, Config.SECRET_KEY);
        String bucketName = "video";
        return ResultGenerator.genSuccessResult(auth.uploadToken(bucketName));
    }
}
